*
* tableToJson()
*
* Ignacio Gutierrez Torrero
* SAIT Software Administrativo
* Monterrey Mexico
*
* Returns the json representation for current table
* Warning need to be changed for large table, because use dimension aInfo[reccount()]
* For large table should change to create the string record by record.
*
* Try it:
* 		use c:\mydir\mytable
*		cInfo = tableToJson()
*		? cInfo
*		_cliptext = strtran(cInfo, ',{"', ','+chr(13)+'{"')
*		Go to Any Editor and Paste the information
*
function tableToJson
local nRecno,i,oObj, cRetVal
	if alias()==''
		return ''
	endif
	nRecno = recno()
	dimension aInfo[reccount()]
	scan		
		oObj = newObject('myObj','json.prg')
		for i=1 to fcount()
			oObj.set(Field(i),eval(Field(i)))
		next
		aInfo[recno()] = oObj		
	endscan
	goto nRecno
	cRetVal = json_encode(@aInfo)
	if not empty(json_getErrorMsg())
		cRetVal = 'ERROR:'+json_getErrorMsg()
	endif
return cRetVal


